algalcommand.io.xml
Class RootElement

java.lang.Object
  extended by algalcommand.io.xml.Element
      extended by algalcommand.io.xml.RootElement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class RootElement
extends Element
implements java.io.Serializable

This class is used to represent the unnamed root of an XML tree.

Copyright Owner: Michigan State University, license number TEC2011-002101Prov

See Also:
Serialized Form

Field Summary
static java.lang.String ROOT_TAGNAME
          In case the tagname is needed for the root, this is it
 
Constructor Summary
RootElement()
          default constructor
 
Method Summary
static void main(java.lang.String[] r)
          Deprecated. For testing only
protected static Element parseContent(Element root, java.lang.String content)
          Parses the content between the openning and closing tags of an element.
static RootElement parseXML(java.lang.String xml)
          Parses XML into a RootElement, which is an extension of the Element class.
 java.lang.String toString()
          Rebuilds the XML document
 
Methods inherited from class algalcommand.io.xml.Element
addAttribute, addChild, addChild, clone, containsChild, countChildren, getAllAttributeNames, getAttributeValue, getChild, getChildElementsByName, getTagName, hasAttribute, isEmpty, removeAllAttributes, removeAllChildren, removeAttribute, removeChild, removeChild, setAttribute, setTagName, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT_TAGNAME

public static final java.lang.String ROOT_TAGNAME
In case the tagname is needed for the root, this is it

See Also:
Constant Field Values
Constructor Detail

RootElement

public RootElement()
default constructor

Method Detail

parseXML

public static RootElement parseXML(java.lang.String xml)
                            throws java.lang.IllegalArgumentException
Parses XML into a RootElement, which is an extension of the Element class.

Parameters:
xml - XML document as a String
Returns:
A RootElement whose children are top level of text and tags from the provided XML
Throws:
java.lang.IllegalArgumentException - Thrown if there was a syntax error in the XML.

parseContent

protected static Element parseContent(Element root,
                                      java.lang.String content)
                               throws java.lang.IllegalArgumentException
Parses the content between the openning and closing tags of an element. This is a recursive function that calls itself to parse the contents of the elements within this content

Parameters:
root - The root element who is the owner of this content
content - XML from between root's opening and closing tags.
Returns:
Returns root, after parsing its content.
Throws:
java.lang.IllegalArgumentException - Thrown if there was a syntax error in the XML.

toString

public java.lang.String toString()
Rebuilds the XML document

Overrides:
toString in class Element
Returns:
A String of the XML representation of this XML tree

main

public static void main(java.lang.String[] r)
Deprecated. For testing only

Parameters:
r -